package com.scnu.common.result;

import com.github.pagehelper.PageInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
 * 封装分页查询结果
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PageVo implements Serializable {

    private long total; //总记录数

    private List rows; //当前页数据集合

    @SuppressWarnings({ "rawtypes", "unchecked" })
    public static PageVo getPageVo(List<?> list){
        PageVo pageVo = new PageVo();
        pageVo.setTotal(new PageInfo(list).getTotal());
        pageVo.setRows(list);
        return pageVo;
    }

}
